﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using SapB1WebApp.DAL;
using SapB1WebApp.Utils;

namespace SapB1WebApp.BLL
{
    public class SAPTransaction
    {
        public double GetSAPItemPrice(string sapUserName, string sapPassword, string companyDB, string cardCode, string itemCode, float amount, DateTime refDate)
        {
            SAPConnection connect = new SAPConnection();
            return connect.GetSAPItemPrice(sapUserName, sapPassword, companyDB, cardCode, itemCode, amount, refDate);
        }
        public DataTable CreateMarketingDocument(string sapUserName, string sapPassword, string companyDB, string xml, string docType, string docEntry, bool isUpdate)
        {
            try
            {
                DataTable dt = new DataTable();
                SAPConnection connect = new SAPConnection();
                dt = connect.CreateMarketingDocument(sapUserName, sapPassword, companyDB, xml, docType, docEntry, isUpdate);
                return dt;
            }
            catch (Exception ex)
            {
                Log.WriteException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "SystemError", ex);
                return null;
            }
        }
        public DataTable CloseCancelDocument(string sapUserName, string sapPassword, string companyDB, string docType, string docEntry, bool isCancel)
        {
            try
            {
                DataTable dt = new DataTable();
                SAPConnection connect = new SAPConnection();
                dt = connect.CloseCancelDocument(sapUserName, sapPassword, companyDB, docType, docEntry, isCancel);
                return dt;
            }
            catch (Exception ex)
            {
                Log.WriteException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "SystemError", ex);
                return null;
            }
        }
        public DataTable DeleteMarketingDocument(string sapUserName, string sapPassWord, string companyDB, DataTable tblLine, string docType, string key)
        {
            try
            {
                DataTable dt = new DataTable();
                SAPConnection connect = new SAPConnection();
                dt = connect.DeleteMarketingDocument(sapUserName, sapPassWord, companyDB, tblLine, docType, key);
                return dt;
            }
            catch (Exception ex)
            {
                Log.WriteException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "SystemError", ex);
                return null;
            }
        }
    }
}